<?php
/**
 * @package Admin
 * @author Henrique Droog <henridroog@gmail.com>
 * @name Submenu
 * @since 02/04/2011
 * @version 1.0
 */
class Admin_Model_Submenu {

    protected $_action;
    protected $_controller;
    protected $_module;
    protected $_menu;
    protected $_status;
    protected $_name;
    protected $_id;

    public function __construct(array $options = null)
    {
        if (is_array($options)) {
            $this->setOptions($options);
        }
    }

    public function __set($name, $value)
    {
        $method = 'set' . $name;
        if (('mapper' == $name) || !method_exists($this, $method)) {
            throw new Exception('Propriedade de submenu inválida');
        }
        $this->$method($value);
    }

    public function __get($name)
    {
        $method = 'get' . $name;
        if (('mapper' == $name) || !method_exists($this, $method)) {
            throw new Exception('Propriedade de submenu inválida');
        }
        return $this->$method();
    }

    public function setOptions(array $options)
    {
        $methods = get_class_methods($this);
        foreach ($options as $key => $value) {
            $method = 'set' . ucfirst($key);
            if (in_array($method, $methods)) {
                $this->$method($value);
            }
        }
        return $this;
    }
     /* Chaves Estrangeiras */
    public function setAction($action_id)
    {
        $this->_action = $action_id;
        return $this;
    }

    public function getAction()
    {
        return $this->_action;
    }

    public function setController($controller_id)
    {
        $this->_controller = $controller_id;
        return $this;
    }

    public function getController()
    {
        return $this->_controller;
    }

    public function setModule($module_id)
    {
        $this->_module = $module_id;
        return $this;
    }

    public function getModule()
    {
        return $this->_module;
    }

    public function setMenu($menu_id)
    {
        $this->_menu = $menu_id;
        return $this;
    }

    public function getMenu()
    {
        return $this->_menu;
    }
    /* Fim Chaves Estrangeiras */

    public function setStatus($status)
    {
        $this->_status = $status;
        return $this;
    }

    public function getStatus()
    {
        return $this->_status;
    }

    public function setName($text)
    {
        $this->_name = $text;
        return $this;
    }

    public function getName()
    {
        return $this->_name;
    }

    public function setId($id)
    {
        $this->_id = (int) $id;
        return $this;
    }

    public function getId()
    {
        return $this->_id;
    }
}